
package com.git.service;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;

import com.allfirst.service.PersonInfoByNameService;
import com.allfirst.service.PersonInfoByNameService_Service;
import com.allfirst.service.param.ObjectFactory;
import com.allfirst.service.param.PersonInfoByNameServiceRequest;
import com.allfirst.service.param.PersonInfoByNameServiceResponse;


public final class PersonInfoByNameServiceClient {

    private static final QName SERVICE_NAME = new QName("http://service.allfirst.com/", "PersonInfoByNameService");
    private static ObjectFactory factory = new ObjectFactory();

    public static void main(String args[]) throws java.lang.Exception {
        URL wsdlURL = PersonInfoByNameService_Service.WSDL_LOCATION;
        if (args.length > 0 && args[0] != null && !"".equals(args[0])) { 
            File wsdlFile = new File(args[0]);
            try {
                if (wsdlFile.exists()) {
                    wsdlURL = wsdlFile.toURI().toURL();
                } else {
                    wsdlURL = new URL(args[0]);
                }
            } catch (MalformedURLException e) {
                e.printStackTrace();
            }
        }
      
        PersonInfoByNameService_Service ss = new PersonInfoByNameService_Service(wsdlURL, SERVICE_NAME);
        PersonInfoByNameService port = ss.getPersonInfoByNameServiceImplPort();  
        
        System.out.println("Invoking getPersonInfo...");
        PersonInfoByNameServiceRequest request = factory.createPersonInfoByNameServiceRequest();
        request.setSessionId(java.net.URLEncoder.encode("0", "utf-8"));
        request.setName(java.net.URLEncoder.encode("", "utf-8"));
        PersonInfoByNameServiceRequest _getPersonInfo_parameters = request;
        PersonInfoByNameServiceResponse _getPersonInfo__return = port.getPersonInfo(_getPersonInfo_parameters);
        System.out.println("getPersonInfo.result=" + _getPersonInfo__return);

        System.exit(0);
    }
    
    public static PersonInfoByNameServiceResponse getPersonInfoByName(String SessionId,String Name) throws Exception{
        URL wsdlURL = PersonInfoByNameService_Service.WSDL_LOCATION;
      
        PersonInfoByNameService_Service ss = new PersonInfoByNameService_Service(wsdlURL, SERVICE_NAME);
        PersonInfoByNameService port = ss.getPersonInfoByNameServiceImplPort();  
        
        System.out.println("Invoking getPersonInfo...");
        PersonInfoByNameServiceRequest request = factory.createPersonInfoByNameServiceRequest();
        request.setSessionId(java.net.URLEncoder.encode(SessionId, "utf-8"));
        request.setName(java.net.URLEncoder.encode(Name, "utf-8"));
        PersonInfoByNameServiceRequest _getPersonInfo_parameters = request;
        PersonInfoByNameServiceResponse _getPersonInfo__return = port.getPersonInfo(_getPersonInfo_parameters);
        System.out.println("getPersonInfo.result=" + _getPersonInfo__return);

        return _getPersonInfo__return;
    }

}
